package com.cmy.b_claculator.db.entity

import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.ForeignKey.CASCADE
import androidx.room.ForeignKey.RESTRICT
import androidx.room.PrimaryKey



/**
 * 单位名称
 */
@Entity
data class WorkUnitEntity(val name: String){
    @PrimaryKey(autoGenerate = true)
    var id = 0L

}


/**
 * 种类
 */
@Entity
data class WorkSpeciesEntity(val name: String){
    @PrimaryKey(autoGenerate = true)
    var id = 0L
}

/**
 * 单价
 */
@Entity(foreignKeys = [ForeignKey(entity = WorkSpeciesEntity::class,
    parentColumns = arrayOf("id"),
    childColumns = arrayOf("speciesId"), onDelete = RESTRICT),
    ForeignKey(entity = WorkUnitEntity::class,
        parentColumns = arrayOf("id"),
        childColumns = arrayOf("unitId"), onDelete = RESTRICT)])
data class WorkEntity(
    val speciesId: Long,//分类ID
    val unitId: Long,//种类ID
    val price: Double,//价格
    val number: Int,//数量
    val dataId:Long,//单位时间ID
    val describe:String,//描述
){

    @PrimaryKey(autoGenerate = true)
    var id = 0L
}

/**
 * 单天数据
 */
@Entity
data class WorkDataEntity(
    val time: String, //时间 格式为yyyy-MM-dd
    val type: Int,
    val money: Double){

    @PrimaryKey(autoGenerate = true)
    var id = 0L
}

/**
 * 修改状态
 */
data class  WorkDataType(val id:Long,val type: Int)

data class WorkDataMoney(val id:Long,val money: Double)


